package models;

import play.*;
import play.db.jpa.*;
import javax.persistence.*;
import java.util.*;

@Entity
public class ShoppingOrder extends Model {

	public String delivery_address;
	public String order_status;
	public Date dt;
	public double totalPrice;
	public String name;
	public String lastName;
	public String telephone;
	public String email;
	public String payOption;
    
	@OneToMany
    public List<Order_item> order_items = new LinkedList<Order_item>();

	public ShoppingOrder() {
		super();
	}

	
	public ShoppingOrder(List<Order_item> order_items) {
		super();
		this.order_items = order_items;
		
	}


	@Override
	public String toString() {
		return "ShoppingOrder [delivery_address=" + delivery_address
				+ ", order_status=" + order_status + ", dt=" + dt
				+ ", order_items=" + order_items + "]";
	}
	
	public void calculatePrice(){
		
		this.totalPrice = 0;
		
		for(Order_item order : order_items)
			this.totalPrice += order.totalPrice;
			
			
	
	}
    
   
    
    
}
